<?php /* SVN: $Id: index.ctp 2879 2010-08-27 11:08:48Z sakthivel_135at10 $ */ ?>
<?php if( empty($this->request->params['named']['filter'])): ?>

<div class ='js-response'>
  <div class ='js-response'>
  <div class="projectFunds index">
    <div class="l-curve-top">
      <div class="r-curve-top">
        <div class="top-bg"></div>
      </div>
    </div>
    <div class="shad-bg-lft clearfix">
      <div class="shad-bg-rgt">
        <div class="shad-bg">
          <div class="main-section content">
            <div class="comments-block">
              <div class="comments-top">
                <div class="comment clearfix">
                  <h2> <?php echo __l('Backers');?> </h2>
                </div>
              </div>
            </div>
            <?php if (!empty($projectFunds) && empty($this->request->params['named']['type'])): ?>
            <!--<div id="map-container">
              <div id="map"></div>
            </div>-->
            <?php endif; ?>
            <?php endif; ?>
           
              <?php if(($project['Project']['user_id'] == $this->Auth->user('id') || $this->Auth->user('user_type_id') == ConstUserTypes::Admin)): 
if($project['Project']['project_status_id'] == ConstProjectStatus::FundingClosed || $project['Project']['project_status_id'] == ConstProjectStatus::GoalReached || $project['Project']['project_status_id'] == ConstProjectStatus::ReserveAmountReached):

?>
              <div class="clearfix">
                <ul class="list filter-list-block backer-list list-active clearfix">
				<li class=" js-pagination <?php if (!empty($this->request->params['named']['filter']) && $this->request->params['named']['filter'] == 'all') { echo 'active';} ?>"><span class="blue-block" title="<?php echo __l('All'); ?>"><?php echo $this->Html->link($this->Html->cInt($all_count,false).'<span>' .__l('All'). '</span>', array('controller'=>'project_funds','action'=>'index','project_id' => $this->request->params['named']['project_id'],'filter'=>'all'), array('escape' => false));?></span> </li>
                <li class="js-pagination<?php if (!empty($this->request->params['named']['filter']) && $this->request->params['named']['filter'] == 'given') { echo 'active';} ?>"><span class="green-block" title="<?php echo __l('Given'); ?>"><?php echo $this->Html->link($this->Html->cInt($given_count,false).'<span>' .__l('Given'). '</span>', array('controller'=>'project_funds','action'=>'index','project_id' => $this->request->params['named']['project_id'],'filter'=>'given'), array('escape' => false));?></span> </li>
                <li class="js-pagination <?php if (!empty($this->request->params['named']['filter']) && $this->request->params['named']['filter'] == 'not_given') { echo 'active';} ?>"><span class="green-block" title="<?php echo __l('Not Given'); ?>"><?php echo $this->Html->link($this->Html->cInt($not_given_count,false).'<span>' .__l('Not Given'). '</span>', array('controller'=>'project_funds','action'=>'index','project_id' => $this->request->params['named']['project_id'],'filter'=>'not_given'), array('escape' => false));?></span> </li>
                </ul>
              </div>
              <?php
endif;
endif; ?>
              <ol class="list comments-list">
                <?php
if (!empty($projectFunds)):
$i = 0;
foreach ($projectFunds as $projectFund):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' altrow';
	}
?>
                <li class="round-5 list-row clearfix <?php echo $class ?>">
                  <div class="avatar grid_2">
                    <?php 
							if(!empty($projectFund['User']['id'])) {
								echo $this->Html->getUserAvatar($projectFund['User']['id'],'normal_thumb'); 
							} else {
								echo __l('User Deleted');
							}	
						?>
                  </div>
                  <div class="data backers-details grid_8">
                    <div class="listing-head clearfix">
                      <h3><?php echo $this->Html->link($this->Html->cText($projectFund['User']['username']), array('controller'=> 'users', 'action' => 'view', $projectFund['User']['username']), array('escape' => false));?></h3>
                      <p class="meta date-block-info"><?php echo $this->Html->cDate($projectFund['ProjectFund']['created']);?></p>
                    </div>
                    <?php if (!empty($projectFund['User']['unique_project_fund_count']) && $projectFund['User']['unique_project_fund_count'] > 1) :
							$other_count = $projectFund['User']['unique_project_fund_count'] - 1;
						?>
                    <p class="clearfix backers-count"> <span><?php echo __l('Backing'). ' ';  ?></span> <?php echo $this->Html->link($this->Html->cInt($other_count, false), array('controller' => 'users', 'action' => 'view', $projectFund['User']['username'], '#Projects_Funded'), array('class' => 'backers-icon', 'title' => $this->Html->cInt($other_count, false))); ?> <span><?php echo ' ' . __l('other projects.'); ?></span> </p>
                    <?php endif; ?>
                    <span class="rewarded"> <?php echo $this->Html->cText($projectFund['ProjectReward']['reward']?$projectFund['ProjectReward']['reward']:__l('No reward'));?> </span>
                    <div class="manage-rewards-links">
                      <?php
						if ((($projectFund['ProjectFund']['user_id'] == $this->Auth->user('id') && (Configure::read('Project.is_allow_pledge_cancel_by_backer'))) || ($projectFund['Project']['user_id'] == $this->Auth->user('id') && (Configure::read('Project.is_allow_pledge_cancel_by_owner'))) || $this->Auth->user('user_type_id') == ConstUserTypes::Admin) && ($projectFund['Project']['project_status_id'] == ConstProjectStatus::OpenForFunding) && (strtotime('+'.Configure::read('Project.minimum_days_before_pledge_cancel').' days') < strtotime($projectFund['Project']['project_funding_end_date'].'23:59:59'))) :?>
                      <span>
                      <?php
							if ($projectFund['ProjectFund']['is_cancelled']) :
								echo __l('Refunded');
							else:
								echo $this->Html->link(__l('Cancel Pledge'), array('controller'=> 'project_funds', 'action' => 'edit_fund', 'project_fund' => $projectFund['ProjectFund']['id'], 'type' => 'cancel'), array('escape' => false, 'class' => 'js-cancel-pledge cancel-refund', 'title' => __l('Cancel Pledge')));
							endif;
						?>
                      </span>
                      <?php
    		       endif; ?>
                      <?php if ($projectFund['Project']['user_id'] == $this->Auth->user('id')): ?>
                      <span><?php echo $this->Html->link(__l('Contact backer'), array('controller' => 'messages', 'action' => 'compose', 'user' => $projectFund['User']['username'],'project_id'=>$projectFund['ProjectFund']['project_id']), array('class' => 'backers-message js-colorbox cboxelement msg', 'escape' => false,'title'=>__l('Contact backer'))); ?></span>
                      <?php if(!empty($projectFund['ProjectFund']['project_reward_id']) && ($projectFund['Project']['project_status_id'] == ConstProjectStatus::FundingClosed || $projectFund['Project']['project_status_id'] == ConstProjectStatus::GoalReached || $projectFund['Project']['project_status_id'] == ConstProjectStatus::ReserveAmountReached)): ?>
                      <span><?php echo $this->Html->link(__l('Print voucher'), array('controller' => 'project_funds', 'action' => 'view', $projectFund['ProjectFund']['id'],'type'=>'print'), array('escape' => false,'target'=>'_blank','class' => 'print', 'title'=>__l('Print voucher'))); ?></span>
                      <?php endif; ?>
                      <?php endif; ?>
                      <?php if ($projectFund['Project']['user_id'] == $this->Auth->user('id') && !empty($projectFund['ProjectFund']['project_reward_id']) && ($projectFund['Project']['project_status_id'] == ConstProjectStatus::FundingClosed || $projectFund['Project']['project_status_id'] == ConstProjectStatus::GoalReached || $projectFund['Project']['project_status_id'] == ConstProjectStatus::ReserveAmountReached)): ?>
                      <span class='js-given-response'>
                      <?php if(empty($projectFund['ProjectFund']['is_given'])): ?>
                      <?php echo $this->Html->link(__l('Given'), array('controller' => 'project_funds', 'action' => 'reward_update', $projectFund['ProjectFund']['id']), array('class'=>'not-given js-given {"title":"'.__l('Given').'"}','escape' => false,'title'=>__l('Given'))); ?>
                      <?php else: ?>
                      <?php echo $this->Html->link(__l('Not given'), array('controller' => 'project_funds', 'action' => 'reward_update', $projectFund['ProjectFund']['id']), array('class'=>'given js-given {"title":"'.__l('Not given').'"}','escape' => false,'title'=>__l('Not given'))); ?>
                      <?php endif; ?>
                      </span>
                      <?php endif; ?>
                    </div>
                  </div>
                  <?php  if ($project['Project']['user_id'] == $this->Auth->user('id') || ($projectFund['ProjectFund']['user_id'] == $this->Auth->user('id')) || (Configure::read('Project.is_show_backers_amount_for_guest_users')) || (Configure::read('Project.is_show_other_backers_amount_for_backers') && $backer) || $this->Auth->user('user_type_id') == ConstUserTypes::Admin) :?>
                  <div class="grid_3 money-block-right alpha omega">
                    <p> <span class="pledge-amount amount-highlight"> <?php echo Configure::read('site.currency') . $this->Html->cCurrency($projectFund['ProjectFund']['amount']);?> </span> </p>
                  </div>
                  <?php endif; ?>
                </li>
                <?php
    endforeach;
else:
?>
                <li>
                  <p class="notice"><?php echo __l('No backers available');?></p>
                </li>
                <?php
endif;
?>
              </ol>
              <div  class="js-pagination">
                <?php
if (!empty($projectFunds)) {
    echo $this->element('paging_links');
}
?>
              </div>
            
            <?php if( empty($this->request->params['named']['filter'])): ?>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="l-curve-bot">
    <div class="r-curve-bot">
      <div class="bot-bg"></div>
    </div>
  </div>
  </div>
</div>
<?php endif; ?>
